package com.example.repository;

import com.example.model.LearningPath;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.data.domain.Pageable;

import java.util.List;

@Repository
public interface LearningPathRepository extends JpaRepository<LearningPath, Long> {
    
    @Query("SELECT DISTINCT lp.topic FROM LearningPath lp ORDER BY lp.createTime DESC")
    List<String> findRecentTopics(Pageable pageable);
    
    List<LearningPath> findByTopicContaining(String topic);
    
    @Query("SELECT lp FROM LearningPath lp WHERE lp.questions IS NOT EMPTY ORDER BY lp.createTime DESC")
    List<LearningPath> findAllWithQuestions();
} 